// Copyright (c) Appeon. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using System.Threading;

namespace SnapObjects.Data
{
    internal interface IMapperChangeTracker
    {
        IModelEntry GetModelEntry(object model);

        void Track(Action<ISaveContext> saveAction);

        void Track(IMapperTrackable mapperTrackable, params object[] saveParms);

        TModel Track<TModel>(IModelEntry<TModel> modelEntry, bool changedOnly, Action<ISaveContext> beforeSaveAction, Action<ISaveContext> afterSaveAction);

        void AddTracker<TModel>(TModel model, IMapperTracker tracker, bool isCascadeModel = false);

        void TrackCreate<TModel>(TModel model, Action<ISaveContext> beforeSaveAction, Action<ISaveContext> afterSaveAction);

        void TrackUpdate<TModel>(TModel model, Action<ISaveContext> beforeSaveAction, Action<ISaveContext> afterSaveAction);

        void TrackUpdate<TModel>(TModel originalModel, TModel modifiedModel, Action<ISaveContext> beforeSaveAction, Action<ISaveContext> afterSaveAction);

        void TrackDelete<TModel>(TModel model, Action<ISaveContext> beforeSaveAction, Action<ISaveContext> afterSaveAction);

        void TrackSqlCUD(string sqlText, params object[] parameters);

        void TrackSqlCUD(DataContext context, ISqlInsertBuilder insertBuilder, params object[] parameters);

        void TrackSqlCUD(DataContext context, ISqlDeleteBuilder deleteBuilder, params object[] parameters);

        void TrackSqlCUD(DataContext context, ISqlUpdateBuilder updateBuilder, params object[] parameters);

        IDbResult Update(DataContext context);

        Task<IDbResult> UpdateAsync(DataContext context, CancellationToken cancellationToken);

        IList<ValidationResult> ValidateAll();

        bool RemoveTrackedModel<TModel>(TModel model);

        void RemoveAllTracked();
    }
}
